var util = require('../../utils/util');
var wxApi = require('../../utils/wxApi');
var wxRequest = require('../../utils/wxRequest');
import config from '../../utils/config';

var app = getApp();
var that;

var inputContent = {};
 
Page({
  data: {
    user: {}
    ,prevPage:null
    ,istb:true
    ,yzm:{data:"",date:null}
    ,blyzm:true
    ,blreg:true
    ,regtext:""
    ,sheight:450
    ,sheight1:450*0.2
    ,sheight2:450*0.7
  },
  onLoad: function (options) {
    that = this;
    
    wx.getSystemInfo({
      success: function(res) {
        that.setData({
          sheight  : res.windowHeight,
          sheight1 :res.windowHeight *0.2,
          sheight2 :res.windowHeight *0.7
        })
      }
    })
    that.loadData();
  },
  onReady: function () {
  },
  onShareAppMessage: function () {
      return app.getShare();
  },
  loadData:function(){
    util.showLoading();
    
    var pages = getCurrentPages();
    that.data.prevPage = pages[pages.length - 2];
    var user =
    that.setData({
      user:that.data.prevPage.data.user
    });

    wx.setNavigationBarTitle( { title: that.data.prevPage.data.team.name });

    util.hideLoading();
  }
  //提交
  ,btnGetkb:function(){

    var pwd = inputContent["pwd"];
    if(!pwd || pwd.length != 6 ){
      util.alert("请输入6位密码");
      return false;
    }

    if(pwd != that.data.prevPage.data.team.pwd){
      util.alert("密码不正确，请查证");
      return false;
    }

    that.data.prevPage.data.sgback=1;
    wx.navigateBack({delta: 1});

    //   
    // that.data.prevPage.setData({
    //   isgl:true,
    //   'kbobj.kbxf':kbxf,
    //   'kbobj.kb':kbnow
    // });

    // util.alert("保存成功,快去领取Kb吧!",function(){
    //   wx.navigateBack({
    //     delta: 1
    //   })
    // });

  },
  btnTbzh:function(){
    
  }
  ,bindChange: function(e) {
    inputContent[e.currentTarget.id] = e.detail.value

  },
  radioChange: function(e) {
    inputContent[e.currentTarget.id] = e.detail.value
    var items = this.data.items;
    for (var i = 0, len = items.length; i < len; ++i) {
      items[i].checked = items[i].value == e.detail.value
    }
    this.setData({
      items: items
    });
  },
  checkMobile :function (str) {
    var re = /^1[34578]\d{9}$/;
    if (re.test(str)) {
      return true;
        //alert("正确");
    } else {
      return false;
    }
  }

})